package 字符串;

import java.util.Scanner;

public class 一的个数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            String str = i+"";
            for (int j = 0; j < str.length(); j++) {
                if (String.valueOf(str.charAt(j)).equals("1")){
                    sum = sum +1;
                }
            }
        }
        System.out.println(sum);
    }
}
